Welcome to R

Session 1

Luis F. Gómez L.

Distance Learning Faculty

10 September, 2025

Please Read Me

  • Purpose

    • Deliver essential knowledge within a minimal timeframe by employing hands-on learning techniques to enhance productivity in the R programming language

Forgetting curves

Figure 1: Learning and forgetting curves

  • Practicing and forgetting curves (PBC, 2023)
Figure 2: Practicing and forgetting curves

Installing R, RStudio IDE and Quarto

(a) R: Engine
(b) RStudio IDE: Dashboard
Figure 3: Analogy of difference between R and RStudio

  • What is Quarto?

Figure 4: Quarto workflow

  • Download and install R: https://cloud.r-project.org/

    • Download R for Linux (Debian, Fedora/Redhat, Ubuntu)
    • Download R for macOS
    • Download R for Windows
  • Download and install RStudio IDE: https://posit.co/download/rstudio-desktop/

    • Windows 10/11
    • macOS 11+
    • Ubuntu 18/Debian 10, Ubuntu 20/Debian 11, Ubuntu 22, Fedora 19/Red Hat 7, OpenSUSE 15, Fedora 34/Red Hat 8, Fedora 36/Red Hat 9

  • Using R and Quarto via RStudio IDE (Ismay & Kim, 2020, Chapter 1)

    • Don’t worry about Quarto because it will be embedded in RStudio IDE
      • If you are using posit Cloud don’t worry about anything!!!
(a) R: Do not open this
(b) RStudio IDE: Open this
Figure 5: R versus RStudio IDE icons on your computer

R packages

(a) R: A new phone
(b) R packages: Apps you can download
Figure 6: Analogy of R vs R packages

  • Installing the tidyverse as an example

    • Copy and paste this code in the console. If you have already installed the tidyverse nothing will happen but if you don’t have installed the tidyverse then the package is going to be installed

    • Installing a package is like downloading an app from a store where you need to do it only once

packages <- c("tidyverse")
for (package in packages) {
  if (!(package %in% rownames(installed.packages()))) {
    install.packages(package)
  }
}
  • Loading a package

    • Loading a package is like opening an app you already installed on your phone where you need to do it every time you want to use the app
library(tidyverse)

Please help me: Errors, warnings, and messages

  • Error: Generally when there’s an error, the code will not run and a message will try to explain what went wrong (Ismay et al., 2025, Chapter 1)
x <- c(1, 2, 3, 4, 5)
X
Error: object 'X' not found
sqrt(-9)
Warning in sqrt(-9): NaNs produced
[1] NaN

packages<-c("tidyverse")
for(package in packages) {
  if(!(package %in% rownames(installed.packages()))) {
    install.packages(package)
  }
}
library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.5.2     ✔ tibble    3.3.0
✔ lubridate 1.9.4     ✔ tidyr     1.3.1
✔ purrr     1.1.0     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors

R for Marketing Research and Analytics, 2nd Ed

Acknowledgments

References

Chapman, C., & Feit, E. M. (2019). R For Marketing Research and Analytics (2nd ed. 2019). Springer International Publishing : Imprint: Springer. https://doi-org.ezproxy.umng.edu.co/10.1007/978-3-030-14316-9
Ismay, C., & Kim, A. Y.-S. (2020). Statistical inference via data science: A ModernDive into R and the tidyverse. CRC Press, Taylor & Francis Group. https://moderndive.com/index.html
Ismay, C., Kim, A. Y., & Valdivia, A. (2025). Statistical Inference via Data Science: A ModernDive into R and the Tidyverse (2nd ed.). Chapman; Hall/CRC. https://moderndive.com/v2/
PBC, P. (2023). Learning Python for Data Science with Posit Academy - YouTube. https://www.youtube.com/live/IpUhSZPqTaE?feature=share&t=401
Wickham, H., Çetinkaya-Rundel, M., & Grolemund, G. (2023). R for data science: Import, tidy, transform, visualize, and model data (Second edition). O’Reilly. https://r4ds.hadley.nz/